package com.itheima.mall.controller;


import cn.hutool.captcha.LineCaptcha;
import com.itheima.mall.pojo.Subject;
import com.itheima.mall.service.CmsSubjectService;
import com.itheima.mall.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService cmsSubjectService;
    //根据专题名称分页获取商品专题
    @GetMapping("/list")
    public ResponseEntity subjectList(String keyword , @RequestParam(defaultValue = "1") Integer pageNum , @RequestParam(defaultValue = "10") Integer pageSize){
       PageResult pageResult = cmsSubjectService.subjectList(keyword ,pageNum , pageSize);
       return ResponseEntity.ok(pageResult);
    }
    //获取全部商品专题
    @GetMapping("/listAll")
    public ResponseEntity subjectListAll(){
        List<Subject>  list = cmsSubjectService.subjectListAll();
        return ResponseEntity.ok(list);
    }
}
